from flask import render_template
from flask import current_app
from info.models import Category
from info.module.sgxc import sgxc_blu


@sgxc_blu.route('/sgxc')
def about_us():
    """施工现场页面展示"""

    # 分类查询的逻辑
    news_list = []
    try:
        news_list = Category.query.all()
    except Exception as e:
        current_app.logger.error(e)

    # 定义一个空的字典列表，里面装的就是字典
    news_dict_li = []
    # 遍历对象列表，将对象的字典添加到字典列表中
    for news in news_list:
        news_dict_li.append(news.to_dict())

    data = {
        "news_dict_li": news_dict_li
    }

    return render_template('sgxc.html', data=data)